{
  "name": "Case 57: Mystery Shopper Report Analyzer",
  "nodes": [
    {
      "parameters": {
        "path": "mystery-shopper-report",
        "formTitle": "Mystery Shopper Report Upload",
        "formDescription": "Upload completed mystery shopper evaluation report",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Upload Report (PDF/Image)",
              "fieldType": "file",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "id": "ef02ee93-098e-42ee-a052-fc5408ffb1c2",
      "name": "Report Upload Form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.1,
      "position": [
        -992,
        -64
      ],
      "webhookId": "mystery-shopper-report"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.cloud.llamaindex.ai/api/v1/parsing/upload",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj"
            }
          ]
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "Upload_Report__PDF_Image_"
            }
          ]
        },
        "options": {}
      },
      "id": "09da6c4a-04b9-4f00-93b4-9f0e11f5508d",
      "name": "Upload Report",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -816,
        -64
      ]
    },
    {
      "parameters": {
        "amount": 20
      },
      "id": "6e54d9ca-05cb-4f36-938e-e7a59cabb0f8",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        -640,
        -64
      ],
      "webhookId": "a78919e5-97a2-4903-968d-800aa4c3c8ee"
    },
    {
      "parameters": {
        "url": "=https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $node[\"Upload Report\"].json[\"id\"] }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj"
            }
          ]
        },
        "options": {}
      },
      "id": "c8d48a7c-c327-41b7-89fa-61181d219eeb",
      "name": "Check Status",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -496,
        -64
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "SUCCESS",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "SUCCESS"
            },
            {
              "conditions": {
                "conditions": [
                  {
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "PENDING",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "PENDING"
            }
          ]
        },
        "options": {}
      },
      "id": "8675cb83-08c6-4d32-be4d-eb8d75c47d12",
      "name": "Router",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        -336,
        -64
      ]
    },
    {
      "parameters": {
        "url": "=https://api.cloud.llamaindex.ai/api/v1/parsing/job/{{ $node[\"Upload Report\"].json[\"id\"] }}/result/markdown",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer llx-7BWYrvPwfUhgdXbZMtaNCsr2O0h7JH4dkHjHisxcvq46bkIj"
            }
          ]
        },
        "options": {}
      },
      "id": "7795de51-2003-4b99-afbf-dfdb9ff6733d",
      "name": "Get Data",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -144,
        -144
      ]
    },
    {
      "parameters": {
        "text": "={{ $json.markdown }}",
        "attributes": {
          "attributes": [
            {
              "name": "Report_ID",
              "description": "Report ID"
            },
            {
              "name": "Store_Name",
              "description": "Store name"
            },
            {
              "name": "Store_Location",
              "description": "Store location"
            },
            {
              "name": "Visit_Date",
              "description": "Visit date YYYY-MM-DD"
            },
            {
              "name": "Cleanliness_Score",
              "description": "Store cleanliness category score (decimal)"
            },
            {
              "name": "Product_Score",
              "description": "Product availability score (decimal)"
            },
            {
              "name": "Service_Score",
              "description": "Customer service score (decimal)"
            },
            {
              "name": "Checkout_Score",
              "description": "Checkout experience score (decimal)"
            },
            {
              "name": "Atmosphere_Score",
              "description": "Store atmosphere score (decimal)"
            },
            {
              "name": "Staff_Appearance_Score",
              "description": "Staff appearance score (decimal)"
            },
            {
              "name": "Positive_Observations",
              "description": "Positive observations text"
            },
            {
              "name": "Negative_Observations",
              "description": "Negative observations text"
            },
            {
              "name": "Critical_Issues",
              "description": "Critical issues mentioned"
            }
          ]
        },
        "options": {}
      },
      "id": "7d13d70e-9647-4349-bd0b-32bdabefecfd",
      "name": "Extract Data",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1.2,
      "position": [
        48,
        -144
      ]
    },
    {
      "parameters": {
        "jsCode": "const e=$node[\"Extract Data\"].json.output||{};const WEIGHTS={service:0.30,cleanliness:0.25,product:0.20,checkout:0.15,atmosphere:0.10};const THRESHOLDS={excellent:85,good:70,needsImprovement:50};const clean=parseFloat(e.Cleanliness_Score||0);const prod=parseFloat(e.Product_Score||0);const serv=parseFloat(e.Service_Score||0);const check=parseFloat(e.Checkout_Score||0);const atm=parseFloat(e.Atmosphere_Score||0);const staff=parseFloat(e.Staff_Appearance_Score||0);const overall=((serv*20*WEIGHTS.service)+(clean*20*WEIGHTS.cleanliness)+(prod*20*WEIGHTS.product)+(check*20*WEIGHTS.checkout)+(atm*20*WEIGHTS.atmosphere)).toFixed(1);const categories=[{name:'Customer Service',score:serv,weight:WEIGHTS.service,impact:serv*WEIGHTS.service},{name:'Store Cleanliness',score:clean,weight:WEIGHTS.cleanliness,impact:clean*WEIGHTS.cleanliness},{name:'Product Availability',score:prod,weight:WEIGHTS.product,impact:prod*WEIGHTS.product},{name:'Checkout Experience',score:check,weight:WEIGHTS.checkout,impact:check*WEIGHTS.checkout},{name:'Store Atmosphere',score:atm,weight:WEIGHTS.atmosphere,impact:atm*WEIGHTS.atmosphere}].sort((a,b)=>a.score-b.score);const top3=categories.slice(0,3);const improvements=top3.map((c,i)=>{let action='';if(c.name==='Customer Service'){action=c.score<3?'Implement mandatory greeting protocol. Reduce staff response time to under 2 minutes. Conduct customer service training.':'Improve staff proactivity and product knowledge through training sessions.';}else if(c.name==='Store Cleanliness'){action=c.score<3?'Implement hourly cleaning checklist. Address restroom maintenance immediately. Replace damaged entrance mat.':'Increase cleaning frequency during peak hours. Regular restroom inspections.';}else if(c.name==='Checkout Experience'){action=c.score<3?'Open additional checkout counters during peak hours (3-7 PM). Improve transaction speed training.':'Optimize checkout staffing schedule. Implement courtesy protocols.';}else if(c.name==='Product Availability'){action='Monitor stock levels more frequently. Improve inventory management system.';}else{action='Maintain current standards with periodic quality checks.';}return{area:c.name,currentScore:c.score.toFixed(1),action};});let rating='';let priority='';let alertTo='';if(parseFloat(overall)>=THRESHOLDS.excellent){rating='EXCELLENT';priority='LOW';alertTo='Store Manager (Recognition)';}else if(parseFloat(overall)>=THRESHOLDS.good){rating='GOOD';priority='MEDIUM';alertTo='Store Manager';}else if(parseFloat(overall)>=THRESHOLDS.needsImprovement){rating='NEEDS IMPROVEMENT';priority='HIGH';alertTo='Store Manager + Regional Manager';}else{rating='CRITICAL';priority='URGENT';alertTo='Store Manager + Regional Manager + Operations Director';}const nextReview=new Date(Date.now()+(parseFloat(overall)>=THRESHOLDS.excellent?60:parseFloat(overall)>=THRESHOLDS.good?30:14)*86400000).toISOString().split('T')[0];return{Report_ID:e.Report_ID||'NOT_FOUND',Store_Name:e.Store_Name||'NOT_FOUND',Visit_Date:e.Visit_Date||'NOT_FOUND',Overall_Score:overall,Performance_Rating:rating,Top_Improvement_1:`${improvements[0].area} (${improvements[0].currentScore}/5): ${improvements[0].action}`,Top_Improvement_2:`${improvements[1].area} (${improvements[1].currentScore}/5): ${improvements[1].action}`,Top_Improvement_3:`${improvements[2].area} (${improvements[2].currentScore}/5): ${improvements[2].action}`,Critical_Issues:e.Critical_Issues||'None reported',Action_Priority:priority,Alert_Sent_To:alertTo,Next_Review_Date:nextReview,Manager_Name:'Store Manager',Status:rating==='CRITICAL'?'URGENT ACTION REQUIRED':rating==='NEEDS IMPROVEMENT'?'ACTION PLAN NEEDED':'ACTIVE',_full_data:e,_overall:overall,_top3:improvements};"
      },
      "id": "069781dc-ec80-44dd-bf42-b77b249ab572",
      "name": "Analysis Engine",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        336,
        -144
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1TEknY4I5JU8R9SH7e2EJS3_pFYdiSteOWbCVhGys05Q",
          "mode": "list",
          "cachedResultName": "Case 57 - Mystery Shopper Report Analyzer Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TEknY4I5JU8R9SH7e2EJS3_pFYdiSteOWbCVhGys05Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TEknY4I5JU8R9SH7e2EJS3_pFYdiSteOWbCVhGys05Q/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Report_ID": "={{ $json.Report_ID }}",
            "Store_Name": "={{ $json.Store_Name }}",
            "Visit_Date": "={{ $json.Visit_Date }}",
            "Overall_Score": "={{ $json.Overall_Score }}",
            "Performance_Rating": "={{ $json.Performance_Rating }}",
            "Top_Improvement_1": "={{ $json.Top_Improvement_1 }}",
            "Top_Improvement_2": "={{ $json.Top_Improvement_2 }}",
            "Top_Improvement_3": "={{ $json.Top_Improvement_3 }}",
            "Critical_Issues": "={{ $json.Critical_Issues }}",
            "Action_Priority": "={{ $json.Action_Priority }}",
            "Alert_Sent_To": "={{ $json.Alert_Sent_To }}",
            "Next_Review_Date": "={{ $json.Next_Review_Date }}",
            "Manager_Name": "={{ $json.Manager_Name }}",
            "Status": "={{ $json.Status }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Report_ID",
              "displayName": "Report_ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Store_Name",
              "displayName": "Store_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Visit_Date",
              "displayName": "Visit_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Overall_Score",
              "displayName": "Overall_Score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Performance_Rating",
              "displayName": "Performance_Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Top_Improvement_1",
              "displayName": "Top_Improvement_1",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Top_Improvement_2",
              "displayName": "Top_Improvement_2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Top_Improvement_3",
              "displayName": "Top_Improvement_3",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Critical_Issues",
              "displayName": "Critical_Issues",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Action_Priority",
              "displayName": "Action_Priority",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Alert_Sent_To",
              "displayName": "Alert_Sent_To",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Next_Review_Date",
              "displayName": "Next_Review_Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Manager_Name",
              "displayName": "Manager_Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "ae4d883c-0e6a-4100-a76c-18e68ccf2dab",
      "name": "Log to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        496,
        -144
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "LOs2dbk9lby0NfDM",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.Performance_Rating }}",
                    "rightValue": "EXCELLENT",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "bd1ed6a6-93f7-4662-bb14-ee9b45890764"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "RECOGNITION"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.Performance_Rating }}",
                    "rightValue": "CRITICAL",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "5ac8d3bf-fa4b-4831-81c1-0f7cbc02600f"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "URGENT"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b299af8e-5bf5-4658-9dde-f390ca09da04",
                    "leftValue": "={{ $json.Performance_Rating }}",
                    "rightValue": "GOOD",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "STANDARD"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "aefee17d-68f2-405c-b3b9-43fe4cf9d5d4",
                    "leftValue": "={{ $json.Performance_Rating }}",
                    "rightValue": "NEEDS IMPROVEMENT",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "STANDARD"
            }
          ]
        },
        "options": {}
      },
      "id": "6415e0df-20af-4386-b302-174f4c7446c8",
      "name": "Email Router",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        688,
        -144
      ]
    },
    {
      "parameters": {
        "jsCode": "const d=$input.first().json||{};const top3=d._top3||[];return{emailSubject:`✅ Excellent Performance: ${d.Store_Name||'Store'} | Score: ${d.Overall_Score||'N/A'}`,emailBody:`<html><body style=\"font-family:Arial;max-width:700px;margin:0 auto;padding:20px\"><div style=\"background:#10b981;color:white;padding:25px;border-radius:8px\"><h1 style=\"margin:0\">✅ Outstanding Performance</h1><p style=\"margin:5px 0 0 0\">${d.Store_Name||'Store'} | ${d.Visit_Date||'N/A'}</p></div><div style=\"background:#ecfdf5;border-left:4px solid #10b981;padding:15px;margin:20px 0;border-radius:4px\"><strong>Mystery Shopper Score: ${d.Overall_Score||'N/A'}/100 - Excellent!</strong></div><div style=\"background:#f9fafb;padding:20px;border-radius:8px;margin:20px 0\"><h2 style=\"margin:0 0 15px 0;font-size:18px;border-bottom:2px solid #e5e7eb;padding-bottom:10px\">Performance Summary</h2><table style=\"width:100%\"><tr><td style=\"padding:8px 0;color:#6b7280\">Overall Score:</td><td style=\"padding:8px 0;font-size:20px;color:#10b981;font-weight:700\">${d.Overall_Score||'N/A'}/100</td></tr><tr><td style=\"padding:8px 0;color:#6b7280\">Rating:</td><td style=\"padding:8px 0;font-weight:700;color:#10b981\">${d.Performance_Rating||'N/A'}</td></tr><tr><td style=\"padding:8px 0;color:#6b7280\">Visit Date:</td><td style=\"padding:8px 0\">${d.Visit_Date||'N/A'}</td></tr></table></div><div style=\"background:#eff6ff;border:2px solid #3b82f6;border-radius:8px;padding:20px;margin:20px 0\"><h3 style=\"margin:0 0 15px 0;color:#1e40af\">Continuous Improvement Areas</h3><p style=\"margin:0 0 10px 0\"><strong>1.</strong> ${d.Top_Improvement_1||'N/A'}</p><p style=\"margin:0 0 10px 0\"><strong>2.</strong> ${d.Top_Improvement_2||'N/A'}</p><p style=\"margin:0\"><strong>3.</strong> ${d.Top_Improvement_3||'N/A'}</p></div><div style=\"background:#f0fdf4;border:2px solid #059669;padding:15px;border-radius:8px;margin:20px 0\"><p style=\"margin:0;color:#047857\"><strong>Recognition:</strong> Excellent work maintaining high standards! Continue current practices.</p></div></body></html>`,recipientEmail:'store.manager@company.com'};"
      },
      "id": "b1c32410-82ce-4b04-a01e-ee92fb4ceb26",
      "name": "Build Recognition Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        896,
        -256
      ]
    },
    {
      "parameters": {
        "jsCode": "const d=$input.first().json||{};return{emailSubject:`🚨 URGENT: Critical Issues at ${d.Store_Name||'Store'} | Score: ${d.Overall_Score||'N/A'}`,emailBody:`<html><body style=\"font-family:Arial;max-width:700px;margin:0 auto;padding:20px\"><div style=\"background:#dc2626;color:white;padding:25px;border-radius:8px\"><h1 style=\"margin:0\">🚨 CRITICAL: Immediate Action Required</h1><p style=\"margin:5px 0 0 0\">${d.Store_Name||'Store'} | ${d.Visit_Date||'N/A'}</p></div><div style=\"background:#fee2e2;border-left:4px solid #dc2626;padding:15px;margin:20px 0;border-radius:4px\"><strong>Mystery Shopper Score: ${d.Overall_Score||'N/A'}/100 - Below Acceptable Standards</strong></div><div style=\"background:#f9fafb;padding:20px;border-radius:8px;margin:20px 0\"><h2 style=\"margin:0 0 15px 0;font-size:18px;border-bottom:2px solid #e5e7eb;padding-bottom:10px\">Performance Analysis</h2><table style=\"width:100%\"><tr><td style=\"padding:8px 0;color:#6b7280\">Overall Score:</td><td style=\"padding:8px 0;font-size:20px;color:#dc2626;font-weight:700\">${d.Overall_Score||'N/A'}/100</td></tr><tr><td style=\"padding:8px 0;color:#6b7280\">Rating:</td><td style=\"padding:8px 0;font-weight:700;color:#dc2626\">${d.Performance_Rating||'N/A'}</td></tr><tr><td style=\"padding:8px 0;color:#6b7280\">Priority:</td><td style=\"padding:8px 0;font-weight:700;color:#dc2626\">${d.Action_Priority||'N/A'}</td></tr></table></div><div style=\"background:#fef3c7;border:2px solid #f59e0b;border-radius:8px;padding:20px;margin:20px 0\"><h3 style=\"margin:0 0 15px 0;color:#92400e\">Critical Issues</h3><p style=\"margin:0;color:#92400e\">${d.Critical_Issues||'See detailed report'}</p></div><div style=\"background:#fee2e2;border:2px solid #dc2626;border-radius:8px;padding:20px;margin:20px 0\"><h3 style=\"margin:0 0 15px 0;color:#991b1b\">Top 3 Areas Requiring IMMEDIATE Improvement</h3><p style=\"margin:0 0 15px 0;padding-bottom:15px;border-bottom:1px solid #fecaca\"><strong>1.</strong> ${d.Top_Improvement_1||'N/A'}</p><p style=\"margin:0 0 15px 0;padding-bottom:15px;border-bottom:1px solid #fecaca\"><strong>2.</strong> ${d.Top_Improvement_2||'N/A'}</p><p style=\"margin:0\"><strong>3.</strong> ${d.Top_Improvement_3||'N/A'}</p></div><div style=\"background:#eff6ff;border:2px solid #3b82f6;padding:20px;border-radius:8px;margin:20px 0\"><h3 style=\"margin:0 0 10px 0;color:#1e40af\">Required Actions</h3><p style=\"margin:0\">Action plan must be submitted within 48 hours. Regional manager will conduct follow-up visit within 7 days.</p></div></body></html>`,recipientEmail:'store.manager@company.com',regionalEmail:'regional.manager@company.com',opsEmail:'operations.director@company.com'};"
      },
      "id": "c7537b42-aa6a-4a92-9ae9-064bd9c76f6d",
      "name": "Build Urgent Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        896,
        96
      ]
    },
    {
      "parameters": {
        "jsCode": "const d=$input.first().json||{};return{emailSubject:`📊 Mystery Shopper Report: ${d.Store_Name||'Store'} | Score: ${d.Overall_Score||'N/A'}`,emailBody:`<html><body style=\"font-family:Arial;max-width:700px;margin:0 auto;padding:20px\"><div style=\"background:#3b82f6;color:white;padding:25px;border-radius:8px\"><h1 style=\"margin:0\">📊 Mystery Shopper Report</h1><p style=\"margin:5px 0 0 0\">${d.Store_Name||'Store'} | ${d.Visit_Date||'N/A'}</p></div><div style=\"background:#dbeafe;border-left:4px solid #3b82f6;padding:15px;margin:20px 0;border-radius:4px\"><strong>Mystery Shopper Score: ${d.Overall_Score||'N/A'}/100 - ${d.Performance_Rating||'N/A'}</strong></div><div style=\"background:#f9fafb;padding:20px;border-radius:8px;margin:20px 0\"><h2 style=\"margin:0 0 15px 0;font-size:18px;border-bottom:2px solid #e5e7eb;padding-bottom:10px\">Performance Summary</h2><table style=\"width:100%\"><tr><td style=\"padding:8px 0;color:#6b7280\">Score:</td><td style=\"padding:8px 0;font-weight:700;font-size:18px\">${d.Overall_Score||'N/A'}/100</td></tr><tr><td style=\"padding:8px 0;color:#6b7280\">Rating:</td><td style=\"padding:8px 0;font-weight:600\">${d.Performance_Rating||'N/A'}</td></tr><tr><td style=\"padding:8px 0;color:#6b7280\">Next Review:</td><td style=\"padding:8px 0\">${d.Next_Review_Date||'N/A'}</td></tr></table></div><div style=\"background:#fef3c7;border:2px solid #f59e0b;border-radius:8px;padding:20px;margin:20px 0\"><h3 style=\"margin:0 0 15px 0;color:#92400e\">Top 3 Improvement Areas</h3><p style=\"margin:0 0 15px 0;padding-bottom:15px;border-bottom:1px solid #fde68a\"><strong>1.</strong> ${d.Top_Improvement_1||'N/A'}</p><p style=\"margin:0 0 15px 0;padding-bottom:15px;border-bottom:1px solid #fde68a\"><strong>2.</strong> ${d.Top_Improvement_2||'N/A'}</p><p style=\"margin:0\"><strong>3.</strong> ${d.Top_Improvement_3||'N/A'}</p></div></body></html>`,recipientEmail:'store.manager@company.com'};"
      },
      "id": "880da0b6-910d-42f1-bf32-22a92ad90a20",
      "name": "Build Standard Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        896,
        -80
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {}
      },
      "id": "732a6939-4494-49b2-b070-d8e5e4adbffc",
      "name": "Send Recognition",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1136,
        -256
      ],
      "webhookId": "22a1212d-ddc8-40e0-bac9-101d2a6f98fd",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {
          "ccList": "={{ $json.regionalEmail }},={{ $json.opsEmail }}"
        }
      },
      "id": "6c17726e-bdce-4264-a583-b928bba9442a",
      "name": "Send Urgent",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1136,
        96
      ],
      "webhookId": "6eb4217a-9efa-49e7-9beb-51740b85c75e",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $json.recipientEmail }}",
        "subject": "={{ $json.emailSubject }}",
        "message": "={{ $json.emailBody }}",
        "options": {}
      },
      "id": "faf0bcb0-ab6f-469b-86cb-ddb51b0af9d0",
      "name": "Send Standard",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1136,
        -80
      ],
      "webhookId": "9a68f444-d13c-4d1a-9f60-c440ff90187f",
      "credentials": {
        "gmailOAuth2": {
          "id": "cyqCGWcggZNMcSOv",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list"
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "7996c60a-6669-46e1-9b34-9588c023794f",
      "name": "GPT-4o Mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        80,
        48
      ],
      "credentials": {
        "openAiApi": {
          "id": "ICwxUBbatsF2sDvy",
          "name": "OpenAi account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Report Upload Form": {
      "main": [
        [
          {
            "node": "Upload Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Report": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Router": {
      "main": [
        [
          {
            "node": "Get Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data": {
      "main": [
        [
          {
            "node": "Extract Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Data": {
      "main": [
        [
          {
            "node": "Analysis Engine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analysis Engine": {
      "main": [
        [
          {
            "node": "Log to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Sheet": {
      "main": [
        [
          {
            "node": "Email Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Router": {
      "main": [
        [
          {
            "node": "Build Recognition Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Urgent Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Standard Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Standard Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Recognition Email": {
      "main": [
        [
          {
            "node": "Send Recognition",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Urgent Email": {
      "main": [
        [
          {
            "node": "Send Urgent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Standard Email": {
      "main": [
        [
          {
            "node": "Send Standard",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4o Mini": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Data",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a506e5e8-6f5e-41fd-968f-91dbbe9e1afb",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "3a43da28588548e21903e71cf1dc3ddd65c24bf0c62e7e4b77542ffe87ad79c6"
  },
  "id": "dyf7LofjxiqGKbQg",
  "tags": []
}